package main

import (
	"net"
	"net/rpc"

	"gitee.com/lcc_dr/rpc/rpc_interface/service"
)

/*
1、自定义一个函数
2、注册到rpc
3、rpc 启动

*/
var _ service.HelloService = (*HelloService)(nil)

type HelloService struct{}

func (h *HelloService) Hello(requests string, response *string) error {
	*response = "hello " + requests
	return nil
}

func main() {

	rpc.RegisterName(service.SERVICE_NAME, &HelloService{})

	listner, err := net.Listen("tcp", ":1234")
	if err != nil {
		panic(err)
	}

	for {
		conn, err := listner.Accept()
		if err != nil {
			panic(err)

		}
		go rpc.ServeConn(conn)

	}
}
